package com.keyroy.game.puzzle_rpg.models.render;

import java.awt.Point;
import java.util.List;

import com.keyroy.game.puzzle_rpg.models.interfaces.SWTDrawable;
import com.keyroy.game.puzzle_rpg.models.puzzle.PuzzleMap;
import com.keyroy.game.puzzle_rpg.models.puzzle.PuzzleUtil;
import com.keyroy.game.puzzle_rpg.models.puzzle.Result;
import com.keyroy.game.puzzle_rpg.models.puzzle.Tile;

public class TipsRender extends SWTDrawable {
	private PuzzleMap puzzleMap;
	private List<Result> results;
	private Object sign;
	private int ox, oy;

	public TipsRender(PuzzleMap puzzleMap) {
		this.puzzleMap = puzzleMap;
		sign = getImage(PuzzleMap.class, "/res/quickassist_obj.gif");

		ox = (puzzleMap.getPuzzleSet().gridWidth - imageWidth(sign)) / 2;
		oy = (puzzleMap.getPuzzleSet().gridHeight - imageHeight(sign)) / 2;
	}

	public void setResults(List<Result> results) {
		this.results = results;
	}

	@Override
	protected void onDraw() {
		if (results != null) {
			for (int i = 0; i < results.size(); i++) {
				Result result = results.get(i);
				List<Point> points = result.points;
				for (int j = 0; j < points.size(); j++) {
					Tile tile = PuzzleUtil.findTile(puzzleMap, points.get(j));
					drawImage(sign, tile.getCx() + ox, tile.getCy() + oy);
				}
			}
		}
	}

}
